package old;

import utils.IntStrPair;

import java.io.*;
import java.util.*;

@SuppressWarnings("unchecked")
public class Old implements Runnable {
    
    private void solve() throws IOException {
        Map<String, List<IntStrPair>> result = OldVocabulary.parseResult("../db");
        Map<String, Integer> part = OldVocabulary.parsePartsOfSpeech("../part-of-speech.txt", result);
        for (String word : part.keySet()) {
            System.err.println(OldVocabulary.PART_STR.charAt(part.get(word)) + " " + word);
            int[] cnt = new int[OldVocabulary.PN + 1];
            for (IntStrPair p : result.get(word)) {
                Integer prt = part.get(p.s);
                if (prt == null) prt = OldVocabulary.PN;
                cnt[prt] += p.x;
            }
            int cntAll = 0;
            for (int i = 0; i <= OldVocabulary.PN; i++) cntAll += cnt[i];
            for (int i = 0; i < OldVocabulary.PN; i++) {
                System.err.println("  " + OldVocabulary.PART_STR.charAt(i) + " " + cnt[i]*1./cntAll + " (" + cnt[i] + " of " + cntAll + ")");
            }
            System.err.println("  unknown " + cnt[OldVocabulary.PN]*1./cntAll + " (" + cnt[OldVocabulary.PN] + " of " + cntAll + ")");
        }
        /*
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        String s = br.readLine();
        List<IntStrPair> l = result.get(s);
        out.print(s + ":");
        if (l == null) {
            out.println(" ---");
        } else {
            String ans = "";
            for (int i = 0; i < 5 && i < l.size() && l.get(i).x > 1; i++) {
                ans += " " + l.get(i).s + "(" + l.get(i).x + ")";
            }
            out.println(ans);
        }
        out.flush();
        */
    }
    
    
    public void run() {
        long startTime = System.nanoTime();
        try {
            solve();
        } catch (IOException e) {
            System.err.println(e.getClass().getName() + ": " + e.getMessage());
            e.printStackTrace();
        }
        long finishTime = System.nanoTime();
        System.err.printf("%.3f\n", (finishTime - startTime) / 1e9);
    }

    public static void main(String[] args) {
        new Thread(new Old()).start();
    }

}
